package timor.timor;

import android.app.Application;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;

import java.util.ArrayList;


public class MyPhotoActivity extends ActionBarActivity {

    private ArrayList<String> list;
    private static MyAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_photo);
        MyApplication application = (MyApplication) getApplication();
        list = application.getList();
        adapter = new MyAdapter();
        GridView gridView= (GridView) findViewById(R.id.myphoto_gridview);
        gridView.setAdapter(adapter);
    }
    class  MyAdapter extends BaseAdapter{


        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = getLayoutInflater().inflate(R.layout.item_myphoto_gridview, null);
            ImageView image = (ImageView) view.findViewById(R.id.item_myphoto_imageview);
            Bitmap bitmap = BitmapFactory.decodeFile(list.get(position));
            image.setImageBitmap(bitmap);
            return view;
        }
    }



}
